const path = require('path')

function resolve(dir) {
    return path.join(__dirname, dir)
}

const name = process.env.VUE_APP_TITLE || 'Ikness追剧助手' // 网页标题

module.exports = {
    // publicPath: process.env.NODE_ENV === 'production' ? './' : '/' ,
    devServer: {
        open: true,
        port: 8088,
        proxy: {
            [process.env.VUE_APP_BASE_URL]: {
                target: `http://localhost:9000`,
                changeOrigin: true,
                pathRewrite: {
                    ['^' + process.env.VUE_APP_BASE_URL]: ''
                }
            },
            '/api': {
                target: process.env.VUE_APP_API_SERVER1,
                changeOrigin: true,
                pathRewrite: {
                    '^/api': '/'
                }
            },
            '/bpi': {
                target: 'https://api.bilibili.com/',
                changeOrigin: true,
                secure: false,
                pathRewrite: {
                    '^/bpi': '/'
                },
                headers: {
                    Referer: process.env.VUE_APP_API_BILIBILI
                }
            },
            '/bangumi': {
                target: 'https://www.bilibili.com/',
                changeOrigin: true,
                secure: false,
                pathRewrite: {
                    '^/bangumi': '/bangumi'
                },
                headers: {
                    Referer: 'https://www.bilibili.com'
                }
            },
        }
    },
    configureWebpack: {
        name: name,
        resolve: {
            alias: {
                '@': resolve('src')
            }
        },
    },
}
